#ifndef _BUOLA_SCENE_IMPORT_CIVPARSER_H_
#define _BUOLA_SCENE_IMPORT_CIVPARSER_H_

#include <buola/scene.h>
#include <buola/io/curi.h>
#include <buola/mat/transformations.h>

#include <stack>

namespace buola { namespace scene { namespace import {

class CIVParser
{
    struct ANodeStart;
    struct ANodeEnd;
    struct APropertyStart;
    struct A3DVector;
    struct A4DVector;
    struct AInteger;
    
    struct SGroup
    {
        std::string mName;
        std::vector<int> mPolygons;
    };

public:
    CIVParser();
    ~CIVParser();

private:

public:
    PMesh Parse(const io::CURI &pURI,double pScale);

    std::vector<mat::CVec3d> *mCurrentVector;
    std::vector<int> *mCurrentIntVector;
    std::vector<mat::CVec3d> *mCurrentMaterialVector;
    
    std::vector<mat::CVec3d> mPositions;
    std::vector<mat::CVec3d> mNormals;
    std::vector<mat::CVec4d> mMaterials;
    std::vector<int> mMaterialIndices;
    std::vector<int> mCoordIndices;
    std::vector<int> mNormalIndices;
    
    std::stack<uint32_t> mNodeStack;
    
    bool mMaterialMode;
    uint32_t mCurrentProperty;
    
    friend struct ANodeStart;
    friend struct ANodeEnd;
    friend struct APropertyStart;
    friend struct A3DVector;
    friend struct A4DVector;
    friend struct AInteger;
};

/*namespace import*/ } /*namespace scene*/ } /*namespace buola*/ }

#endif